/*
 * @Author: atony2099
 * @Date: 2019-02-13 13:53:17
 * @Last Modified by: atony2099
 * @Last Modified time: 2019-02-15 07:49:16
 */
'use strict';
const uuidv4 = require('uuid/v4');

module.exports = app => {
  app.ready(async function() {
    // init adim User
    const User = app.mongoose.model('User');
    const user = await User.findOne({
      loginname: 'admin',
    });

    if (!user) {
      await User.create({
        loginname: 'admin',
        username: 'tony',
        password: app.createMD5('admin'),
        token: uuidv4(),
      });
    }
  });
};
